---
layout: "default"
title: "MapCollectionView"
description: "Swift documentation for 'MapCollectionView': A CollectionType whose elements consist of those in a Base."
keywords: "MapCollectionView,struct,swift,documentation,generate,endIndex,startIndex,Generator,Element,Index,SubSequence"
root: "/v1.2"
---

<div class="intro-declaration"><code class="language-swift">struct MapCollectionView&lt;Base : CollectionType, T&gt;</code></div>

<div class="discussion comment">
    <p>A <code>CollectionType</code> whose elements consist of those in a <code>Base</code>
<code>CollectionType</code> passed through a transform function returning <code>T</code>.
These elements are computed lazily, each time they&#39;re read, by
calling the transform function on a base element.</p>
</div>

<table class="standard">
<tr>
<th id="inheritance">Inheritance</th>
<td>
<code class="inherits">CollectionType, SequenceType, _CollectionType, _SequenceType, _Sequence_Type</code>
<span class="viz"><a href="hierarchy/">View Protocol Hierarchy &rarr;</a></span>
</td>
</tr>

<tr>
<th id="aliases">Associated Types</th>
<td>
<span id="aliasesmark"></span>
<div class="declaration">
<code class="language-swift">Generator = MapSequenceGenerator&lt;Base.Generator, T&gt;</code>
<div class="comment">
    <p><em>Type alias inferred.</em></p>
</div>
</div>
<div class="declaration">
<code class="language-swift">Element = T</code>
<div class="comment">
    <p><em>Type alias inferred.</em></p>
</div>
</div>
<div class="declaration">
<code class="language-swift">Index = Base.Index</code>
<div class="comment">
    <p><em>Type alias inferred.</em></p>
</div>
</div>
<div class="declaration">
<code class="language-swift">SubSequence = Slice&lt;MapCollectionView&lt;Base, T&gt;&gt;</code>
<div class="comment">
    <p><em>Type alias inferred.</em></p>
</div>
</div>
</td>
</tr>


<tr>
<th>Import</th>
<td><code class="language-swift">import Swift</code></td>
</tr>

</table>




<h3>Instance Variables</h3>
<div class="declaration" id="var-endindex_-base-index">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-endindex_-base-index">var endIndex: Base.Index</a><div class="comment collapse" id="comment-var-endindex_-base-index"><div class="p">
    <p>The collection&#39;s &quot;past the end&quot; position.</p>

<p><code>endIndex</code> is not a valid argument to <code>subscript</code>, and is always
reachable from <code>startIndex</code> by zero or more applications of
<code>successor()</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var endIndex: Base.Index { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-startindex_-base-index">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-startindex_-base-index">var startIndex: Base.Index</a><div class="comment collapse" id="comment-var-startindex_-base-index"><div class="p">
    <p>The position of the first element in a non-empty collection.</p>

<p>Identical to <code>endIndex</code> in an empty collection.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var startIndex: Base.Index { get }</code>

    </div></div>
</div>

<h3>Subscripts</h3>
<div class="declaration" id="subscript-subscript_-base-index">
<a class="toggle-link" data-toggle="collapse" href="#comment-subscript-subscript_-base-index">subscript(_: Base.Index)</a>
<div class="comment collapse" id="comment-subscript-subscript_-base-index"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">subscript(position: Base.Index) -&gt; T { get }</code>
    
    
</div></div>
</div>


<h3>Instance Methods</h3>
<div class="declaration" id="func-generate">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-generate">func generate()</a>
        
<div class="comment collapse" id="comment-func-generate"><div class="p">
    <p>Return a <em>generator</em> over the elements of this <em>sequence</em>.</p>

<p>Complexity: O(1)</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func generate() -&gt; MapSequenceGenerator&lt;Base.Generator, T&gt;</code>
    
    
</div></div>
</div>


